﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nvn.Core.MVP;
using Hutech.CRM.Library.Views;
using Hutech.CRM.Library.Models.BusinessAccessLayer;
using Hutech.CRM.Library.Models.BusinessAccessLayer.BusinessObjects;
using Hutech.CRM.Library.Models.Entities;
using nvn.Library.Patterns;
using Hutech.CRM.Library.Utilities;

namespace Hutech.CRM.Library.Presenters
{
    public class AddAndViewCustomerPresenter : BasePresenter<IAddAndViewCustomerView>
    {
        #region First Description
        public AddAndViewCustomerPresenter(IAddAndViewCustomerView view)
            : base(view)
        {
            this.view.FristLoadEventHandler += new EventHandler<EventArgs>(view_FristLoadEventHandler);
            this.view.Save_Click += new EventHandler<SaveEventAgrs<AccountCustomer>>(view_Save_Click);
            this.view.Cancel_Click += new EventHandler<EventArgs>(view_Cancel_Click);
        }

        
        #endregion

        #region All Event
        void view_FristLoadEventHandler(object sender, EventArgs e)
        {
            //view.HeaderPopup = "Create new";
            //view.GroupLevelCustomers = LoadGroupLevelCustomer();
            //view.ShowPopup = true;
        }
        void view_Cancel_Click(object sender, EventArgs e)
        {
        }
        void view_Save_Click(object sender, SaveEventAgrs<AccountCustomer> e)
        {
            IAccountCustomerBAL itemBAL = new AccountCustomerBAL();
            AccountCustomer item = e.myType;

            item.IsDelete = false;
            item.LastUpdatedDate = DateTime.Now;
            item.Level = ConstantVariable.VALUE_LEVEL_1;
            //se them ham kiem tra level dau tien cho nay

            if (itemBAL.Save(item))
            {
            }
            else
            {
            }
        }
        #endregion

        #region private method
        //List<TowTypeParameters<Guid,string>> LoadGroupLevelCustomer()
        //{
        //    CriterionCustomerBAL itemBAL = new CriterionCustomerBAL();
        //    return itemBAL.GetGroupLevelCustomers();
        //}
        //void RefreshAllControl() 
        //{
        //    view.GroupLevelCustomers = LoadGroupLevelCustomer();
        //    view.CriterionName = string.Empty;
        //}
        #endregion
    }
}
